/*
 * =====================================================================================
 *       Filename:  e3-1.cpp
 *
 *    Description:  
 *
 *        Created:  2009年10月18日 00时05分31秒
 *       Revision:  none
 *         Author:  Santal Li (santal), santal.li@gmail.com
 * =====================================================================================
 */

#include <iostream>
#include <cstdlib>
#include <list>

#include "../commons/collections.h"

using namespace std ;

// l p is sort list, show print 
void printLots(const list<int> l , const list<int> p){

    list<int>::const_iterator li= l.begin();
    int i  = 0  ;
    for(list<int>::const_iterator pi = p.begin()  ; pi != p.end(); pi++ ){
        while((i != *pi) && (li != l.end())){
            li++ , i++ ;
        }
        cout << "location:" << *pi <<" value:" << *li << endl ;
    }
} 


// this is the lunch point, for start exercise
int main(){

    int larray[] = { 0 , 1 ,2, 3, 4, 5, 6, 7, 8, 9 };
    list<int> l(larray , larray + sizeof( larray ) / sizeof(int)  ) ;

    int parray[] = {3 , 5, 8} ;
    list<int> p(parray , parray + sizeof( parray ) / sizeof(int)  ) ;
    
    cout << "the target list:" << endl ;
    printCollection(l);
    printCollection(p);

    cout << "result" << endl ;
    printLots( l , p ) ;
}
